#include <iostream>
#include <stdio.h>

using namespace std;

struct Node
{
    int data;
    Node *next;
    Node *pre;
};

int main()
{
    Node *p1 = new Node;
    Node *head = new Node;
    Node *tail = new Node;

    int n;
    scanf("%d",&n);
    head->next = p1;
    head->pre = NULL;
    p1->pre = head;
    p1->next = tail;
    tail->pre = p1;
    tail->next = NULL;

    p1->data = 1;
    for (int i = 2; i <= n; i++)
    {   
        Node* p;
        int k, flag;
        scanf("%d%d",&k,&flag);
        Node *r = new Node;
        for (p = head ; p->data != k; p = p->next);
        if (flag)
        {
            p->next->pre = r;
            r->next = p->next;
            r->pre = p;
            p->next = r;
            r->data = i;
        }
        else
        {
            p->pre->next = r;
            r->pre = p->pre;
            r->next = p;
            p->pre = r;
            r->data = i;
        }
    }

    Node* p;
    for (p = head->next; p != tail; p = p->next)
    {
        printf("%d ",p->data);
    }
    return 0;
}